from os import name
from odoo import fields, models, api
from odoo.exceptions import UserError


class RpThirdPriceAdjustRule(models.Model):
    
    _name = "rp.third.price.adjust.rule"
    _description = '第三方承运商调价规则'

    type = fields.Selection([("number", "数值"), ("rate", "比例")], "调价类型")
    
    value = fields.Float("调价值", required=True)
    
    def name_get(self):
        res = []
        for s in self:
            name = dict(self._fields['type'].selection).get(s.type) + ":" + str(s.value)
            res.append((s.id, name))
        return res